export default {
  state: () => ({
    token: "",
    userInfo: {},
    secret: "",
    currentService: "",
    allPermission: [],
    userId: '',
    merchantId: "",
    adminType: "",
    routerKey: Number(new Date()),
    currentMenuId: null,
    organizationId: '',
    screenTime: [],
    openDataScreen: null,
    globalServeType: null,
    mallId: null,
    queryConditionObj: {},
    keepAliveInclude: [],
    secretEnabled: false,
    merchant: null,
    loginPath: ''
  }),
  actions: {
    login(
      { state, commit }: any,
      { token, username, currentService, allPermission, merchantId, adminType, userId, secret, secretEnabled, merchant }: any
    ) {
      commit("SETUERID", userId);
      commit("SETTOKEN", token);
      commit("SETUSERNAME", username);
      commit("SETCURRENTSERVICE", currentService);
      commit("SETALLPERMISSION", allPermission);
      commit("SETMERCHANTID", merchantId);
      commit("SETADMINTYPE", adminType);
      commit("SETMERCHANT", merchant)
    },
    logout({ state, commit }: any, redirct = "") {
      commit("SETUERID", "");
      commit("SETTOKEN", "");
      commit("SETUSERNAME", "");
      commit("SETCURRENTSERVICE", "");
      commit("SETALLPERMISSION", []);
      commit("SETMERCHANTID", "");
      commit("SETADMINTYPE", "");
      commit("SETMERCHANT", null)
      // commit("SETSECRET", "");
      // commit("SETSECRETENABLED", false);
    },
  },
  mutations: {
    SETTOKEN(state: any, data: any) {
      state.token = data;
    },
    SETUERID(state: any, data: any) {
      state.userId = data;
    },
    SETINSID(state: any, data: any) {
      state.insId = data
    },
    SETUSERNAME(state: any, data: any) {
      state.username = data;
    },
    SETBINDWX(state: any, data: any) {
      state.bindWx = data
    },
    SETCURRENTSERVICE(state: any, data: any) {
      state.currentService = data;
    },
    SETALLPERMISSION(state: any, data: any) {
      state.allPermission = data;
    },
    SETMERCHANTID(state: any, data: any) {
      state.merchantId = data;
    },
    SETADMINTYPE(state: any, data: any) {
      state.adminType = data;
    },
    SETROUTERKER(state: any, data: any) {
      state.routerKey = data;
    },
    SETCURRENTMENUID(state: any, data: any) {
      state.currentMenuId = data;
    },
    SETORGANIZATIONID(state: any, data: any) {
      state.organizationId = data;
    },
    SETSCREENTIME(state: any, data: any) {
      state.screenTime = data;
    },
    OPENDATASCREEN(state: any, data: any) {
      state.openDataScreen = data;
    },
    SETUSERINFO(state: any, data: any) {
      state.userInfo = data;
    },
    SETBINDWXPROMPTSTATUS(state: any, data: any) {
      state.bindWxPromptStatus = data
    },
    GLOBALSERVERTYPE(state: any, data: any) {
      state.globalServeType = data;
    },
    SETMALLID(state: any, payload: any) {
      state.mallId = payload
    },
    SETQUERYCONDITIONOBJ(state: any, payload: any) {
      state.queryConditionObj = payload
    },
    SETKEEPALIVEINCLUDE(state: any, data: any) {
      state.keepAliveInclude = data;
    },
    SETSECRET(state: any, payload: any) {
      state.secret = payload
    },
    SETSECRETENABLED(state: any, payload: any) {
      state.secretEnabled = payload
    },
    SETMERCHANT(state: any, data: any) {
      state.merchant = data;
    },
    SETLOGINPATH(state: any, data: any) {
      state.loginPath = data;
    }
  },
};
